package com.code9xs.mapper;

import com.code9xs.pojo.Article;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
@Mapper
public interface ArticleMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Article record);

    int insertSelective(Article record);

    Article selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Article record);

    int updateByPrimaryKeyWithBLOBs(Article record);

    int updateByPrimaryKey(Article record);

    /**
     * 查询所有文章条数
     * @return
     */
    int selectAllCount();

    /**
     * 分页查询所有文章
     * @param start
     * @param pageSize
     * @return
     */
    List<Map<String,Object>> selectArticlePagination(@Param("start")Integer start,@Param("pageSize")Integer pageSize);

    /**
     * 查询所有文章页用户面板信息
     * @return
     */
    Map<String,Object> selectUserInfoBar(@Param("uid") Integer uid);

    List<Map<String,Object>> selectCommentByArticleId(@Param("articleId")Integer articleId);

    /**
     * 查询文章详细信息
     * @param articleId
     * @return
     */
    Map<String,Object> selectArticleItemById(@Param("articleId")Integer articleId);

    /**
     * 根据文章主键查询文章评论条数
     * @param articleId
     * @return
     */
    int selectCommentCount(@Param("articleId") Integer articleId);

    /**
     * 根据用户主键查询当前用户的文章总数
     * @param uid
     * @return
     */
    int selectArticleCountByUid(@Param("uid")Integer uid);

    /**
     * 根据用户主键分页查询用户文章
     * @param uid
     * @param page
     * @param pageSize
     * @return
     */
    List<Map<String,Object>> selectPaginationUserArticleInfoByUid(@Param("uid")Integer uid, @Param("start")Integer start,@Param("pageSize")Integer pageSize);

    /**
     * 根据用户id查询用户总评论数
     * @param uid
     * @return
     */
    int selectCommentCountByUid(@Param("uid") Integer uid);

    int selectAllArticleCount();

    List<Map<String,Object>> selectAllArticlePagination(@Param("start") Integer start,@Param("pageSize") Integer pageSize);

    /**
     * 获取当前点赞数最高的五条文章
     * @return
     */
    List<Map<String,Object>> selectMaxArticle();
}